home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / vtkerma1.arc / MSINTRFC.ASM < prev    next >
Assembly Source File  |  1986-02-13  |  4KB  |  205 lines

  1.     PAGE 59, 132
  2.  
  3.     TITLE MsIntrfc -- Interface between generic and machine-specific code
  4.  
  5. ; Update 6 Jan 86
  6.  
  7. IF1
  8.  %OUT >> Starting pass 1
  9. ELSE
  10.  %OUT >> Starting pass 2
  11. ENDIF
  12.  
  13.     PUBLIC Count, XofSnt, Source, SrcPnt, Preload_buffer, Preload_flag
  14.     PUBLIC Get_Set_Key_table_size, Simulate_port_char
  15.     PUBLIC Type_to_screen, Parse_for_Set_Key
  16.  
  17.     .LALL            ; Show the macro expansions
  18.     .LFCOND            ; List false conditionals
  19.  
  20.     INCLUDE MsDefs.H
  21.  
  22. DataS    SEGMENT PUBLIC 'DataS'
  23.  
  24.     EXTRN PC_Type:BYTE, SetKTab_PC:BYTE, SetKHlp_PC:BYTE
  25.  
  26. Preload_flag DB 0        ; Flag to say we have preloaded a command
  27. Preload_buffer DB 256 DUP (?)    ; Buffer to hold a preloaded command
  28.  
  29. IF RB_Flag
  30.     EXTRN SetKTab_RB:BYTE, SetKHlp_RB:BYTE
  31. ENDIF
  32.  
  33. Count    DW 0            ; Count of chars in port buffer
  34. XofSnt    DB 0            ; Flag that an XOFF has been sent
  35. SrcPnt    DW 0            ; Pointer into buffer (DI)
  36.  
  37. Source    DB BufSiz DUP(?)    ; Buffer for data from port
  38.  
  39. DataS    ENDS
  40.  
  41. Code    SEGMENT PUBLIC
  42.  
  43.     EXTRN Comnd:NEAR
  44.  
  45.     ASSUME cs:Code, ds:DataS, es:DataS
  46.  
  47. Rtn    MACRO NamRtn
  48.  
  49.     PUBLIC NamRtn
  50. NamRtn:
  51.  
  52. IF RB_Flag
  53.     call Check_type     ; Is machine type Rainbow?
  54.      je NamRtn&_is_RB    ;  Yes
  55. ENDIF
  56.  
  57.     EXTRN NamRtn&_PC:NEAR
  58.     jmp NamRtn&_PC        ; Default to IBM PC
  59.  
  60. IF RB_Flag
  61.     EXTRN NamRtn&_RB:NEAR
  62. NamRtn&_is_RB:
  63.     jmp NamRtn&_RB    ; Type is DEC Rainbow
  64. ENDIF
  65.  
  66.     ENDM
  67.  
  68. Check_type PROC
  69.  
  70.     push ax            ; Save a reg
  71.     mov al, PC_Type        ; Get machine type
  72.     cmp al, 2        ; Rainbow?
  73.     pop ax            ; Restore reg
  74.     ret            ; Return with Z flag set if Rainbow
  75.  
  76. Check_type ENDP
  77.  
  78. Routines PROC
  79.  
  80.     Rtn Term        ; Entry to terminal emulator
  81.     Rtn SerIni
  82.     Rtn SerRst
  83.     Rtn Drop_DTR
  84.     Rtn ClrBuf
  85.     Rtn OutChr
  86.     Rtn Coms
  87. ;    Rtn VTS
  88.     Rtn DoDel
  89.     Rtn CtlU
  90.     Rtn CmBlnk
  91.     Rtn Locate
  92.     Rtn LclIni
  93.  
  94.  %OUT >> About half way through source file
  95.  
  96.     Rtn PrtChr
  97.     Rtn DoBaud
  98.     Rtn ClearL
  99.     Rtn DoDisk
  100.     Rtn GetBaud
  101.     Rtn Beep
  102.     Rtn PutHlp
  103.     Rtn PutMod
  104.     Rtn ClrMod
  105.     Rtn PosCur
  106.     Rtn SendBr
  107.     Rtn ShowKey
  108.     Rtn Close_screen
  109.     Rtn Set_up_script_processor
  110.  
  111. ; Routine to parse for the SET KEY command, which is machine-specific
  112.  
  113. Parse_for_Set_Key:
  114.  
  115. IF RB_Flag
  116.     mov dx, OFFSET SetKTab_RB ; Assume Rainbow for now
  117.     mov bx, OFFSET SetKHlp_RB
  118.  
  119.     call Check_type        ; Are we running on a Rainbow?
  120.      je PRS_1        ;  Yes ...
  121. ENDIF
  122.  
  123.     mov dx, OFFSET SetKTab_PC ; No, default to IBM
  124.     mov bx, OFFSET SetKHlp_PC
  125.  
  126. PRS_1:    mov ah, CmKey
  127.     call Comnd
  128.      ret            ; Failure -- return non-skip
  129.      nop
  130.      nop
  131.  
  132.     pop bp            ; Return skip
  133.     add bp, 3
  134.     push bp
  135.         ret
  136.  
  137. ; Routine to return size of Set Key table, machine-specific
  138.  
  139. Get_Set_Key_table_size:
  140.  
  141. IF RB_Flag
  142.     mov al, SetKTab_RB    ; Assume Rainbow for now
  143.  
  144.     call Check_type        ; Are we running on a Rainbow?
  145.      je GSK_1        ;  Yes ...
  146. ENDIF
  147.  
  148.     mov al, SetKTab_PC    ; No, default to IBM
  149.  
  150. GSK_1:    ret            ; Done here
  151.  
  152. Routines ENDP
  153.  
  154.  
  155. ; Simulate receiving a char from port -- used by script's PRINT command (and
  156. ;  others)
  157. ;
  158. ; Call with char in al reg
  159.  
  160. Simulate_port_char PROC
  161.  
  162.     cmp Count, BufSiz    ; Room for another character?
  163.      jl SPC_0        ;  Yes
  164.  
  165.     ret            ; No room, do nothing
  166.  
  167. SPC_0:    push di            ; Save a reg
  168.     mov di, SrcPnt        ; Registers for storing data
  169.     cld            ; Forwards
  170.     stosb            ; Store the character in the buffer
  171.     cmp di, OFFSET Source + BufSiz ; At end of buffer?
  172.      jb SPC_1        ;  Not yet
  173.  
  174.     mov di, OFFSET Source    ; Wrap buffer around
  175.  
  176. SPC_1:    inc Count        ; Bump up the count
  177.     mov SrcPnt, di        ; Store the updated pointer
  178.     pop di            ; Restore reg
  179.     ret            ; That's it
  180.  
  181. Simulate_port_char ENDP
  182.  
  183. Type_to_screen PROC
  184.  
  185.     call Simulate_port_char    ; Cheat
  186.     cmp al, Cr        ; Was it a Cr?
  187.      jne R            ;  No
  188.  
  189.     push ax            ; Save old value
  190.  
  191.     mov al, Lf        ; Yes, load up an Lf
  192.     call Simulate_port_char    ; Turn screen Cr's into CrLf's
  193.  
  194.     pop ax            ; Get back original char
  195.  
  196. R:    ret            ; Done here
  197.  
  198. Type_to_screen ENDP
  199.  
  200.  
  201. Code    ENDS
  202.  
  203.     END
  204. 
  205.